
const { createWebAPIRequest } = require('../../util/util')

module.exports = [
  {
    /**
    * @api {get} /music/personalized [推荐歌单]
    * @apiGroup Music
    * @apiPermission none
    * @apiParam {Number} [offset=0] 页
    * @apiParam {Number} [limit=20]  每页数量
    */
    url: '/music/personalized',
    request: (req, res) => {
      const cookie = req.get('Cookie') || ''
      const data = {
        limit: req.query.limit || 20,
        offset: req.query.offset || 0,
        total: true,
        n: 1000,
        csrf_token: ''
      }
      createWebAPIRequest(
        'music.163.com',
        '/weapi/personalized/playlist',
        'POST',
        data,
        cookie,
        musicReq => {
          res.send(musicReq)
        },
        err => res.status(500).send({err})
      )
    }
  }, {
    /**
    * @api {get} /music/personalized/djprogram [推荐dj]
    * @apiGroup Music
    * @apiPermission none
    */
    url: '/music/personalized/djprogram',
    request: (req, res) => {
      const cookie = req.get('Cookie') ? req.get('Cookie') : ''
      const data = {}
      createWebAPIRequest(
        'music.163.com',
        '/weapi/personalized/djprogram',
        'POST',
        data,
        cookie,
        musicReq => {
          res.send(musicReq)
        },
        err => res.status(500).send({err})
      )
    }
  }, {
    /**
    * @api {get} /music/personalized/newsong [推荐新音乐]
    * @apiGroup Music
    * @apiPermission none
    */
    url: '/music/personalized/newsong',
    request: (req, res) => {
      const cookie = req.get('Cookie') ? req.get('Cookie') : ''
      const data = {
        type: 'recommend'
      }
      createWebAPIRequest(
        'music.163.com',
        '/weapi/personalized/newsong',
        'POST',
        data,
        cookie,
        musicReq => {
          res.send(musicReq)
        },
        err => res.status(500).send({err})
      )
    }
  }, {
    /**
    * @api {get} /music/personalized/mv [推荐MV]
    * @apiGroup Music
    * @apiPermission none
    */
    url: '/music/personalized/mv',
    request: (req, res) => {
      const cookie = req.get('Cookie') ? req.get('Cookie') : ''
      const data = {}
      createWebAPIRequest(
        'music.163.com',
        '/weapi/personalized/mv',
        'POST',
        data,
        cookie,
        musicReq => {
          res.send(musicReq)
        },
        err => res.status(500).send({err})
      )
    }
  }, {
    /**
    * @api {get} /music/personalized/privatecontent [独家放送]
    * @apiGroup Music
    * @apiPermission none
    */
    url: '/music/personalized/privatecontent',
    request: (req, res) => {
      const cookie = req.get('Cookie') ? req.get('Cookie') : ''
      const data = {}
      createWebAPIRequest(
        'music.163.com',
        '/weapi/personalized/privatecontent',
        'POST',
        data,
        cookie,
        musicReq => {
          res.send(musicReq)
        },
        err => res.status(500).send({err})
      )
    }
  }
]
